home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / ex / Circle.c < prev    next >
C/C++ Source or Header  |  1990-05-15  |  1KB  |  69 lines

  1. // Circle.c -- Circle shape
  2.  
  3. #include "Circle.h"
  4. #include "nihclIO.h"
  5.  
  6. #define THIS Circle
  7. #define BASE Shape
  8. #define BASE_CLASSES Shape::desc()
  9. #define MEMBER_CLASSES
  10. #define VIRTUAL_BASE_CLASSES
  11.  
  12. DEFINE_CLASS(Circle,1,"$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/ex/RCS/Circle.c,v 3.0 90/05/15 22:43:29 kgorlen Rel $",NULL,NULL);
  13.  
  14. void Circle::draw() const
  15. {
  16.     printOn();
  17.     cout << endl;
  18. }
  19.  
  20. bool Circle::operator==(const Circle& c) const
  21. {
  22.     if (origin() == c.origin())
  23.         if (rad == c.rad) return YES;
  24.     return NO;
  25. }
  26.  
  27. const Class* Circle::species() const    { return &classDesc; }
  28.  
  29. bool Circle::isEqual(const Object& p) const
  30. {
  31.     return p.isSpecies(classDesc) && *this==(const Circle&)p;
  32. }
  33.  
  34. unsigned Circle::hash() const
  35. {
  36.     return origin().hash() ^ rad;
  37. }
  38.  
  39. void Circle::printOn(ostream& strm) const
  40. {
  41.     strm << "Circle with center " <<
  42.       *TransformStack::transform.current() + origin();
  43.     strm << " and radius " << rad;
  44. }
  45.  
  46. Circle::Circle(OIOin& strm)
  47.     : Shape(strm)
  48. {
  49.     strm >> rad;
  50. }
  51.  
  52. void Circle::storer(OIOout& strm) const
  53. {
  54.     Shape::storer(strm);
  55.     strm << rad;
  56. }
  57.  
  58. Circle::Circle(OIOifd& fd)
  59.     : Shape(fd)
  60. {
  61.     fd >> rad;
  62. }
  63.  
  64. void Circle::storer(OIOofd& fd) const
  65. {
  66.     Shape::storer(fd);
  67.     fd << rad;
  68. }
  69.